import React from 'react';
import ReactDOM from 'react-dom/client';
import apiService from "@service/index";

// 假设这两个类型定义在其他文件中，需要正确引入
// 这里只是示例，实际使用时需要替换为正确的导入路径
// import type { SuggestionResponse, SearchResultResponse } from './types'; 

// 合并搜索联想建议和搜索结果的 API 服务
// const searchApiService = apiService.injectEndpoints({
//   endpoints: (builder) => ({
//     // 搜索-联想建议
//     requestSuggestion: builder.query<SuggestionResponse, string>({
//       query: (key) => ({ url: "/suggestion", params: { q: key } }),
//     }),
//     // 搜索-获取搜索结果
//     requestSearchResult: builder.query<
//       SearchResultResponse,
//       { page: number; per_page: number; q: string }
//     >({
//       query: (params) => ({ url: "/search", params }),
//     }),
//   }),
// });
export const searchApiService = apiService.injectEndpoints({
  endpoints: (builder) => ({
    // 搜索-联想建议
    requestSuggestion: builder.query({
      query: (key) => ({ url: "/suggestion", params: { q: key } }),
    }),
    // 搜索-获取搜索结果
    requestSearchResult: builder.query({
      query: (params) => ({ url: "/search", params }),
    }),
  }),
});

export const { 
  useLazyRequestSuggestionQuery,
  useLazyRequestSearchResultQuery 
} = searchApiService;

// 示例组件，可根据实际情况修改
